from __future__ import annotations

from dataclasses import dataclass


@dataclass
class RiskResult:
    risk_score: float
    level: str
    note: str


def evaluate_risk(likelihood: int, consequence: int, exposure: int = 1) -> RiskResult:
    """简化施工风险评估：R = L × C × E。

    - L: 发生可能性 1~5
    - C: 后果严重性 1~5
    - E: 暴露频次 1~5
    """

    R = float(likelihood * consequence * max(1, exposure))
    if R >= 60:
        lvl = "极高"
    elif R >= 30:
        lvl = "高"
    elif R >= 15:
        lvl = "中"
    else:
        lvl = "低"
    return RiskResult(risk_score=R, level=lvl, note="用于作业前风险研判")


